package com.wenjie.controller;

import com.wenjie.original.entity.common.vo.RestBaseVo;
import com.wenjie.original.entity.vo.Order.OrderUpOrAddVo;
import com.wenjie.original.entity.vo.Order.OrderVo;
import com.wenjie.original.service.IOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("订单信息")
@RestController
@RequestMapping("/api/order")
public class OrderController {

    @Autowired
    private IOrderService orderService;

    @ApiOperation("查询接口")
    @PostMapping("/list")
    public RestBaseVo<OrderVo.ResVo> list(@RequestBody @Validated OrderVo.SelVo selVo) {
        return orderService.list(selVo, OrderVo.ResVo.class);
    }

    @ApiOperation("添加接口")
    @PostMapping("/add")
    public void add(@RequestBody @Validated OrderUpOrAddVo.AddVo addVo) {
        orderService.cusSave(addVo);
    }

    @ApiOperation("修改接口")
    @PostMapping("/up")
    public void up(@RequestBody @Validated OrderUpOrAddVo.UpVo upVo) {
        orderService.updateById(upVo);
    }

    @ApiOperation("删除接口")
    @PostMapping("/del")
    public void del(@RequestBody @Validated Long id) {
        orderService.removeById(id);
    }

}
